package com.an.java.javaall.oj;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main3 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int faceThreshold = Integer.parseInt(scanner.nextLine());
        int facePersons = Integer.parseInt(scanner.nextLine());
        List<FaceRange> faceRangeList = new ArrayList<>();
        for (int i = 0; i < facePersons; i++) {
            String timeRangeStr = scanner.nextLine();
            String[] timeRanges = timeRangeStr.split(" ");
            faceRangeList.add(new FaceRange(Integer.parseInt(timeRanges[0]), Integer.parseInt(timeRanges[1])));
        }
        faceRangeList.sort(Comparator.comparingInt(FaceRange::getStart));
        int sum = 0;
        while (!faceRangeList.isEmpty()) {
            FaceRange faceRange = faceRangeList.get(0);
            faceRangeList.remove(0);
            int tmpIndex = 0;
            int currentFaces = 1;
            while (!faceRangeList.isEmpty() && faceRangeList.size() > tmpIndex && currentFaces < faceThreshold) {
                if (faceRange.getEnd() <= faceRangeList.get(tmpIndex).getStart()) {
                    currentFaces++;
                    faceRange = faceRangeList.get(tmpIndex);
                    faceRangeList.remove(tmpIndex);
                    continue;
                }
                tmpIndex++;
            }
            sum++;
        }
        System.out.println(sum);
    }

}

class FaceRange {
    private int start;
    private int end;

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getEnd() {
        return end;
    }

    public void setEnd(int end) {
        this.end = end;
    }

    public FaceRange(int start, int end) {
        this.start = start;
        this.end = end;
    }
}
